var e = require;
var t = module;
var o = exports;
var n = o;
Object.defineProperty(n, "__esModule", {value: !0});
var i = (function () {
    function e() {
        (this.mapWidth = 0),
            (this.mapHeight = 0),
            (this.unitWidth = 0),
            (this.unitHeight = 0),
            (this.countRow = 0),
            (this.countCol = 0),
            (this.blockInfos = []);
    }
    return (
        (e.prototype.init = function (e, t, o) {
            (this.mapWidth = e),
                (this.mapHeight = e),
                (this.unitWidth = t),
                (this.unitHeight = t),
                (this.countCol = Math.floor(e / t)),
                (this.countRow = Math.floor(e / t));
            for (var n = 0, i = 0; i < this.countRow; i++)
                for (var a = 0; a < this.countCol; a++) {
                    var r = new o();
                    (r.index = n++), (r.row = i), (r.col = a), this.blockInfos.push(r);
                }
        }),
        (e.prototype.getBlockInfoByIndex = function (e) {
            return this.blockInfos[e];
        }),
        (e.prototype.getBlokInfoByPos = function (e) {
            var t = this.getBlockRowAndColByPos(e);
            return this.getBlockInfoByRowAndCol(t.row - 1, t.col - 1);
        }),
        (e.prototype.getRowAndColByIndex = function (e) {
            var t = this.blockInfos[e];
            return {row: t.row, col: t.col};
        }),
        (e.prototype.getIndexByRowAndCol = function (e, t) {
            return e * this.countCol + t;
        }),
        (e.prototype.getBlockRowAndColByPos = function (e) {
            var t = e.x + this.mapWidth / 2,
                o = e.y + this.mapHeight / 2,
                n = Math.ceil(t / this.unitWidth);
            return {row: Math.ceil(o / this.unitHeight), col: n};
        }),
        (e.prototype.getBlockInfoByRowAndCol = function (e, t) {
            return void 0 === t && (t = -999), this.blockInfos[e * this.countCol + t];
        }),
        (e.prototype.getBlockInfosBySize = function (e, t) {
            for (
                var o = this.getBlockRowAndColByPos(e),
                    n = o.row - t <= 0 ? 1 : o.row - 1,
                    i = o.row + t >= this.countRow ? this.countRow : o.row + t,
                    a = o.col - t <= 0 ? 1 : o.col - 1,
                    r = o.col + t >= this.countCol ? this.countCol : o.col + t,
                    s = [],
                    c = n;
                c <= i;
                c++
            )
                for (var l = a; l <= r; l++) {
                    var d = this.getBlockInfoByRowAndCol(c - 1, l - 1);
                    s.push(d);
                }
            return s;
        }),
        (e.prototype.setBlockInfo = function (e) {
            for (var t = 0; t < e.length; t++) {
                var o = e[t];
                this.blockInfos[e[t].index] = o;
            }
        }),
        (e.prototype.addBlockInfo = function (e, t, o) {
            this.blockInfos[e].add(t, o);
        }),
        (e.prototype.removeBlockInfo = function (e, t) {
            this.blockInfos[e].remove(t);
        }),
        (e.prototype.clearBlockPartElement = function (e) {
            for (var t = 0; t < this.blockInfos.length; t++) this.blockInfos[t].clearPartInfo(e);
        }),
        (e.prototype.getCenterPosByIndex = function (e) {
            var t = this.getRowAndColByIndex(e),
                o = t.col * this.unitWidth + this.unitWidth / 2 - this.mapWidth / 2,
                n = t.row * this.unitHeight + this.unitHeight / 2 - this.mapHeight / 2;
            return cc.v3(o, n);
        }),
        e
    );
})();
n.default = i;
